package com.elinshaw;

import org.apache.storm.Config;
import org.apache.storm.StormSubmitter;
import org.apache.storm.topology.TopologyBuilder;

/**
 * 远程demo实现
 * <p>
 * 上传nimbus所在服务器
 * 上传完毕后通过以下命令远程启动storm
 * <p>
 * 远程启动storm的命令是：
 * storm jar  *.jar  main函数全路径名
 * <p>
 * 关闭提交topology
 * storm kill 提交的topology名
 *
 * @author Administrator
 */
public class TopologyRemote {

    public static void main(String[] args) {

        final TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("MySpout", new NumberSpout());
        builder.setBolt("WrapStarBolt", new FirstBolt(), 4).shuffleGrouping("MySpout");
        builder.setBolt("MyWrapBolt", new TimeBolt(), 4).shuffleGrouping("MySpout");
        final Config config = new Config();
        //集群模式提交
        config.setNumWorkers(3);
        try {
            StormSubmitter.submitTopology("myTopologyRemote", config, builder.createTopology());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
